package com.ly.web.controller.erp;

import java.util.List;

import com.ly.heart.domain.SaleMarkedPriceEntity;
import com.ly.heart.service.IKingTravelBusinessReimbursementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.KingTravelBusinessReimbursementEntity;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 差旅费报销单Controller
 * 
 * @author wutao
 * @date 2024-08-23
 */
@Api(value = "reimbursement", tags = "差旅费报销单")
@RestController
@RequestMapping("/heart/reimbursement")
public class KingTravelBusinessReimbursementController extends BaseController {

    @Resource
    private IKingTravelBusinessReimbursementService kingTravelBusinessReimbursementEntityService;

    /**
     * 查询差旅费报销单列表
     */
    @PreAuthorize("@ss.hasPermi('heart:reimbursement:list')")
    @GetMapping("/list")
    @ApiOperation("查询差旅费报销单列表")
    public TableDataInfo list(KingTravelBusinessReimbursementEntity kingTravelBusinessReimbursementEntity)
    {
        startPage();
        List<KingTravelBusinessReimbursementEntity> list = kingTravelBusinessReimbursementEntityService.selectKingTravelBusinessReimbursementEntityList(kingTravelBusinessReimbursementEntity);
        return getDataTable(list);
    }

    /**
     * 导出差旅费报销单列表
     */
    @PreAuthorize("@ss.hasPermi('heart:reimbursement:export')")
    @Log(title = "差旅费报销单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出差旅费报销单列表")
    public AjaxResult export(KingTravelBusinessReimbursementEntity kingTravelBusinessReimbursementEntity)
    {
        List<KingTravelBusinessReimbursementEntity> list = kingTravelBusinessReimbursementEntityService.selectKingTravelBusinessReimbursementEntityList(kingTravelBusinessReimbursementEntity);
        ExcelUtil<KingTravelBusinessReimbursementEntity> util = new ExcelUtil<KingTravelBusinessReimbursementEntity>(KingTravelBusinessReimbursementEntity.class);
        return util.exportExcel(list, "reimbursement");
    }

    /**
     * 获取差旅费报销单详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:reimbursement:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取差旅费报销单详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(kingTravelBusinessReimbursementEntityService.selectKingTravelBusinessReimbursementEntityById(id));
    }

    /**
     * 新增差旅费报销单
     */
    @PreAuthorize("@ss.hasPermi('heart:reimbursement:add')")
    @Log(title = "差旅费报销单", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增差旅费报销单")
    public AjaxResult add(@RequestBody KingTravelBusinessReimbursementEntity kingTravelBusinessReimbursementEntity)
    {
        return toAjax(kingTravelBusinessReimbursementEntityService.insertKingTravelBusinessReimbursementEntity(kingTravelBusinessReimbursementEntity));
    }


    @Log(title = "暂存差旅费报销单", businessType = BusinessType.INSERT)
    @PostMapping("draft")
    @ApiOperation("暂存差旅费报销单")
    public AjaxResult draft(@RequestBody KingTravelBusinessReimbursementEntity kingTravelBusinessReimbursement) {
        AjaxResult ajaxResult = kingTravelBusinessReimbursementEntityService.draft(kingTravelBusinessReimbursement);
        return AjaxResult.success(ajaxResult);
    }

    @Log(title = "提交差旅费报销单", businessType = BusinessType.INSERT)
    @PostMapping("submit")
    @ApiOperation("提交差旅费报销单")
    public AjaxResult submit(@RequestBody KingTravelBusinessReimbursementEntity kingTravelBusinessReimbursement) {
        AjaxResult ajaxResult = kingTravelBusinessReimbursementEntityService.submit(kingTravelBusinessReimbursement);
        return AjaxResult.success(ajaxResult);
    }


    /**
     * 修改差旅费报销单
     */
    @PreAuthorize("@ss.hasPermi('heart:reimbursement:edit')")
    @Log(title = "差旅费报销单", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改差旅费报销单")
    public AjaxResult edit(@RequestBody KingTravelBusinessReimbursementEntity kingTravelBusinessReimbursementEntity)
    {
        return toAjax(kingTravelBusinessReimbursementEntityService.updateKingTravelBusinessReimbursementEntity(kingTravelBusinessReimbursementEntity));
    }

    /**
     * 删除差旅费报销单
     */
    @PreAuthorize("@ss.hasPermi('heart:reimbursement:remove')")
    @Log(title = "差旅费报销单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除差旅费报销单")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kingTravelBusinessReimbursementEntityService.deleteKingTravelBusinessReimbursementEntityByIds(ids));
    }
}
